package com.example.bootdemo.common.util;

import org.springframework.stereotype.Component;

import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;

@Component
public class IntegerChangeString {
    /**
     * 将员工数字状态  转为 文字形式
     *
     * @param employeeStatus
     * @return
     */
    public static String setEmployeeStatus(Integer employeeStatus) {
        String excelEmpStaus = "";
        if (employeeStatus != null) {
            if (employeeStatus == 1) {
                excelEmpStaus = "试用";
            } else if (employeeStatus == 2) {
                excelEmpStaus = "试用-正式";
            } else if (employeeStatus == 3) {
                excelEmpStaus = "正式";
            } else if (employeeStatus == 4) {
                excelEmpStaus = "换项";
            } else if (employeeStatus == 5) {
                excelEmpStaus = "离职";
            }else if (employeeStatus == 6) {
                excelEmpStaus = "待离职";
            }else if (employeeStatus == 7) {
                excelEmpStaus = "入职";
            }
        }
        return excelEmpStaus;
    }

    /**
     * 将员工数字类型  转为 文字形式
     *
     * @param employeeType
     * @return
     */
    public static String setEmployeeType(Integer employeeType) {
        String excelEmpType = "";
        if (employeeType != null) {
            if (employeeType == 1) {
                excelEmpType = "本部";
            } else if (employeeType == 2) {
                excelEmpType = "外派";
            } else if (employeeType == 3) {
                excelEmpType = "实训";
            }
        }
        return excelEmpType;
    }

    /**
     * 将档案信息数字状态  转为 文字形式
     *
     * @param fileStatus
     * @return
     */
    public static String setFileStatus(Integer fileStatus) {
        String excelfileStaus = "";
        if (fileStatus != null) {
            if (fileStatus == 0) {
                excelfileStaus = "无";
            } else if (fileStatus == 1) {
                excelfileStaus = "有";
            }
        }
        return excelfileStaus;
    }

    /**
     * 获取本月执行工资标题后的(年月)
     * @param lastUpdateTime1
     * @return
     */
    public static String getYearAndMonth(Date lastUpdateTime1){
        String append="";
        if (lastUpdateTime1!=null){
            String[] strNow1 = new SimpleDateFormat("yyyy-MM-dd").format(lastUpdateTime1).toString().split("-");
            Integer year=Integer.parseInt(strNow1[0]);			//获取年
            Integer month= Integer.parseInt(strNow1[1]);			//获取月
            if (year!=null&&month!=null){
                append="("+year+"年"+month+"月)";
            }
        }
        return append;
    }

    /**
     * string 转  bigdecimal
     * @param str
     * @return
     */
    public static BigDecimal getBigdecimal(String str) {
        BigDecimal bd = BigDecimal.valueOf(0.0);
        if (str != null) {
            bd=new BigDecimal(str);
        }
        return bd;
    }
}